export { }
// 类与接口类型的应用
// 1. 定义2个不同的接口数据类型
interface Eat {
  eat(food: string): void
}
interface Run {
  run(runName: string): void
  slowRun: (runName: string)=>void
}

// 2. 写一个类，让类去实现接口的规范，也就是让类，必须要有接口里面规定的方法。
//  implements,关键字，实现...
class Person implements Eat, Run{
  uname:string = ''
  constructor(name:string){
    this.uname = name
  }
  eat(food: string): void {
    console.log(`${this.uname}在吃${food}`);
  }

  run(runName: string): void {
    console.log(`${this.uname}在做${runName}运动`);
  }
  slowRun(runName: string): void{
    console.log(`${this.uname}在做${runName}运动`);
  }
}

let p1 = new Person('王宇')
p1.eat('红烧肉')

// 让 Animal 类去实现一个Eat的接口规范
class Animal implements Eat{
  eat(food: string): void {
    console.log(food);
  }
}

new Animal().eat('鱼')